package com.bawei.mall.product.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.bawei.common.core.domain.R;
import com.bawei.mall.product.service.IMallProductAdvertiseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bawei.common.log.annotation.Log;
import com.bawei.common.log.enums.BusinessType;
import com.bawei.common.security.annotation.RequiresPermissions;
import com.bawei.system.domain.MallProductAdvertise;
import com.bawei.common.core.web.controller.BaseController;
import com.bawei.common.core.web.domain.AjaxResult;
import com.bawei.common.core.utils.poi.ExcelUtil;
import com.bawei.common.core.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author bawei
 * @date 2024-07-01
 */
@RestController
@RequestMapping("/advertise")
public class MallProductAdvertiseController extends BaseController
{
    @Autowired
    private IMallProductAdvertiseService mallProductAdvertiseService;

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("system:advertise:list")
    @GetMapping("/list")
    public TableDataInfo list(MallProductAdvertise mallProductAdvertise)
    {
        startPage();
        List<MallProductAdvertise> list = mallProductAdvertiseService.selectMallProductAdvertiseList(mallProductAdvertise);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("system:advertise:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MallProductAdvertise mallProductAdvertise)
    {
        List<MallProductAdvertise> list = mallProductAdvertiseService.selectMallProductAdvertiseList(mallProductAdvertise);
        ExcelUtil<MallProductAdvertise> util = new ExcelUtil<MallProductAdvertise>(MallProductAdvertise.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @RequiresPermissions("system:advertise:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallProductAdvertiseService.selectMallProductAdvertiseById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @RequiresPermissions("system:advertise:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallProductAdvertise mallProductAdvertise)
    {
        return toAjax(mallProductAdvertiseService.insertMallProductAdvertise(mallProductAdvertise));
    }

    /**
     * 修改【请填写功能名称】
     */
    @RequiresPermissions("system:advertise:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallProductAdvertise mallProductAdvertise)
    {
        return toAjax(mallProductAdvertiseService.updateMallProductAdvertise(mallProductAdvertise));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("system:advertise:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallProductAdvertiseService.deleteMallProductAdvertiseByIds(ids));
    }


    /**
     * 广告列表
     */
    @GetMapping("/findlist")
    public R<List<MallProductAdvertise>> list(){
        List<MallProductAdvertise> list=mallProductAdvertiseService.list();
        return R.ok(list);
    }
}
